package com.tunelib.client.managed.ui;

import com.google.gwt.requestfactory.ui.client.ProxyRenderer;

import com.tunelib.client.managed.request.ArtistProxy;

/**
 * Renders {@link ArtistProxy for display to the user. Requires the
 *  properties to have been fetched.
 */
public class ArtistProxyRenderer extends ProxyRenderer<ArtistProxy> {
  private static ArtistProxyRenderer INSTANCE;

  public static ArtistProxyRenderer instance() {
    if (INSTANCE == null) {
      INSTANCE = new ArtistProxyRenderer();
    }

    return INSTANCE;
  }

  protected ArtistProxyRenderer() {
    super(new String[] {"name"});
  }

  public String render(ArtistProxy object) {
    if (object == null) {
      return "";
    }
    return object.getName() + " (" + object.getId() + ")";
  }
}
